<?php 
$host = "localhost";
$port="5432";
$database = "webcosts";
$user= "webcosts"; 
$password="webcosts123";

$db_conn = pg_connect("host=$host port=$port dbname=$database user=$user password=$password");
if (!$db_conn) {
    echo "Failed connecting to postgres database $database\n";
    exit;
}

$qu = pg_query($db_conn, "SELECT * FROM uf ORDER BY nome");

while ($data = pg_fetch_object($qu)) {
    echo $data->id . " (";
    echo $data->nome . "): ";
    echo $data->sigla . "<br />";
}

pg_free_result ($qu);
pg_close ($db_conn);
?>
